#include("../../comm/ListHead.html")
<style>
    .line-img{ padding:0px; margin:0px; width:40px; height:30px }
</style>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-header SearchTable">
            <p style="float:right">
                <input type="text" id="mem_id" lay-verify="required" placeholder="会员ID" autocomplete="off"
                       class="table-search-text width80">
                <input type="text" id="user_nick" lay-verify="required" placeholder="妮称" autocomplete="off"
                       class="table-search-text width80">
                <input type="text" id="open_id" lay-verify="required" placeholder="OpenId" autocomplete="off"
                       class="table-search-text width200">
                <button class="layui-btn layui-btn-warm layui-btn-sm" lay-event="DoSearch">
                    搜索
                </button>
            </p>
            <i class="layui-icon layui-icon-slider"></i>
            当前位置 > <span class="color_green">微信用户列表</span>
        </div>
        <div class="layui-card-body">
            <table class="layui-hide" id="table_1" lay-filter="table_1"></table>

            <script type="text/html" id="table_1_bar_title">
                <span id="bar_desc"></span>
            </script>
        </div>
    </div>
</div>
<script language="JavaScript">

    layui.use(['myTable', 'table', 'form', 'util', 'myTool'], function () {
        var $ = layui.$, myTable = layui.myTable, myTool = layui.myTool;

        tableindex = myTable.render({
            url: 'WxMemberListDataApi'
            , title: '微信用户列表'
            , cols: [[
                {type: 'checkbox', width: 36, fixed:true}
                , {field: 'mem_id', title: '会员ID', width: 60, align: 'center'}
                , {field: 'user_head', title: '头像', width: 60, align: 'center', image: {show: true, class: 'line-img', url: 'user_head'}}
                , {field: 'user_nick', title: '妮称', width: 120}
                , {
                    field: 'test_color', title: '关注', width: 70, align: 'center', templet: function (d) {
                        if (d.sub_tag == 0) {
                            return '<button class="layui-btn layui-btn-xs bg-yellow-500" style="width:26px;">否</button>';
                        } else {
                            return '<button class="layui-btn layui-btn-xs bg-green-600" style="width:26px;">是</button>';
                        }
                    }
                }
                , {field: 'sub_date', title: '关注时间', width: 160}
                , {field: 'union_id', title: '关联ID', width: 150}
                , {field: 'wx_openid', title: '公众号ID', width: 150}
                , {field: 'app_openid', title: '小程序ID', width: 150}
                , {field: 'user_desc', title: '备注'}
                , {field: 'create_dateint', title: '创建日期', width: 80, hide: true}
                , {field: 'create_date', title: '创建时间', width: 150}

            ]]
            , page: true, limit: 10
            , editField: {url: 'ModifyWxUserFieldApi', key: 'open_id'}
            , done: function (res, curr, count) {
                $("#bar_desc").html("共有微信用户 " + count + " 人");
            }
        });

        layui.util.event("lay-event", {
            DoSearch: function () {
                tableindex.reload({
                    where: {
                        s: {
                            open_id: $("#open_id").val(),
                            title: $("#title").val()
                        }
                    }
                    , page: {curr: 1}
                });
            },
            DoSearchMore: function () {
                layui.form.render();
                drawer1.open();
            }
        });

//头工具栏事件
        table.on('toolbar(table_1)', function (obj) {
            myTool.toolbar(this, obj, {
                AddWxUser: function () {
                    index = layer.open({
                        type: 2, offset: '10px', area: ['700px', '550px'], title: ['添加示例数据', 'font-size:18px;'],
                        content: ["AddWxUser", 'no'],
                        end: function () {
                            tableindex.reload({});
                        }
                    });
                }
                , EditWxUser: function () {
                    myTool.doSingleSelect(myTable.checkStatus('table_1'), {}, function (data, keys) {
                        index = layer.open({
                            type: 2, offset: '10px', area: ['700px', '550px'], title: ['修改示例[' + data[0].title + ']', 'font-size:18px;'],
                            content: ["EditWxUser?open_id=" + data[0].open_id, 'no'],
                            end: function () {
                                tableindex.reload({});
                            }
                        });
                    });
                }
                , DelWxUser: function () {
                    myTool.doSingleSelect(myTable.checkStatus('table_1'), {}, function (data, keys) {
                        index = layer.confirm('你是否确认删除【' + data[0].title + '】', {icon: 3, title: '提示', offset: '100px'}, function (index2) {
                            myTool.postMsg("DelWxUserApi", {open_id: data[0].open_id}, function () {
                                layer.close(index2);
                                tableindex.reload();
                            });
                        });
                    });
                }
            });
        });

//监听锁定操作
        form.on('checkbox(LockCom)', function (obj) {
            myTool.postMsg("LockWxUserApi", {hall_id: this.value}, function (result) {
                layer.tips(result.msg, obj.othis);
            });
        });
    });
</script>
#include("../../comm/Foot.html")